//  全局跳转方法
const reLaunch = (url) => {
  uni.reLaunch({
    url: url
  });
}
const navigateTo = (url) => {
  uni.navigateTo({
    url: url
  });
}
const redirectTo = (url) => {
  uni.redirectTo({
    url: url
  });
}
const switchTab = (url) => {
  uni.switchTab({
    url: url
  });
}
const back = (num) => {
  let pageNum = getCurrentPages().length;
  if (pageNum >= 2) {
    if (typeof(num) != 'number') {
      num = 1
    }
    uni.navigateBack({
      delta: num ? num : 1
    });
  } else {
    reLaunch('/pages/index/index');
  }
}

export default {
  reLaunch,
  navigateTo,
  redirectTo,
  switchTab,
  back
}
